package com.pomr.util.common;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;

import com.alibaba.fastjson.serializer.PropertyFilter;

/**
 * 类名称： ComplexPropertyPreFilter
 * 创建人： Administrator
 * 创建时间：2018年5月21日 下午3:33:34
 * 类描述：fastjson序列化hibernate持久化对象时忽略代理的懒加载对象
 */
public class ComplexPropertyPreFilter implements PropertyFilter,Serializable{
	private Map<Class<?>, Set<String>> includeMap = new HashMap<Class<?>, Set<String>>();  
    //@Override  
    public boolean apply(Object source, String name, Object value) {  
        for(Entry<Class<?>, Set<String>> entry : includeMap.entrySet()) {  
            Class<?> class1 = entry.getKey();  
            if(source.getClass() == class1){  
                Set<String> fields = entry.getValue();  
                for(String field : fields) {  
                    if(field.equals(name)){  
                        return false;  
                    }  
                }  
            }  
        }  
        return true;  
    }  

    public ComplexPropertyPreFilter() {
		super();
	}

	public ComplexPropertyPreFilter(Map<Class<?>, Set<String>> includeMap){  
        this.includeMap = includeMap;  
    }  
}
